﻿using Autofac;
using Maintenance.DAL;
using Maintenance.IDAL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Maintenance.DALContainer
{
   public class Container
    {
        public static IContainer container = null;

        public static T Resolve<T>()
        {
            try
            {
                if (container == null)
                {
                    Initialist();
                }
            }
            catch (Exception ex)
            {
                throw new System.Exception(ex.Message);
              
            }
            return container.Resolve<T>();
        }

        private static void Initialist()
        {
            var builder = new ContainerBuilder();
            builder.RegisterType<Guest_UserDAL>().As<IGuest_UserDAL>().InstancePerLifetimeScope();
            container = builder.Build();
        }
    }
}
